﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Bussiness;

namespace WebApplication.Admin.Baocao
{
    public class BaoCaoTonkho
    {
        public IQueryable<BaoCaoton> GetBaoCaoTon(DateTime dt, string ngay)
        {
            var db = dataprovider.Entity.TON_KHO;
            return db.Where(p => p.NGAYTHANG == dt)
                .Select(p => new BaoCaoton 
                {
                    mathang=p.MATHANG.TENMH,
                    tondau=(int)p.SOLUONGDAU,
                    soluongnhap=(int)p.SOLUONGNHAP,
                    soluongxuat=(int)p.SOLUONGXUAT,
                    toncuoi=(int)p.SOLUONGTON,
                    ngay=ngay
                });
            
        }
        public IQueryable<BaoCaoton> GetBaoCaoTon(DateTime dt, string ngay,string mamh)
        {
            var db = dataprovider.Entity.TON_KHO;
            return db.Where(p => p.NGAYTHANG == dt && p.MAMH==mamh)
                .Select(p => new BaoCaoton
                {
                    mathang = p.MATHANG.TENMH,
                    tondau = (int)p.SOLUONGDAU,
                    soluongnhap = (int)p.SOLUONGNHAP,
                    soluongxuat = (int)p.SOLUONGXUAT,
                    toncuoi = (int)p.SOLUONGTON,
                    ngay=ngay
                });

        }
        public class BaoCaoton
        {
            public string mathang { get; set; }
            public int tondau { get; set; }
            public int soluongnhap { get; set; }
            public int soluongxuat { get; set; }
            public int toncuoi { get; set; }
            public string ngay { get; set; }
        }
    }
}